package page6;

import java.util.Scanner;
/**
 * 给你一个长度是n的序列A，然后，有m次询问，每次询问是一个数字X，请你告诉我X在序列A中有多少个数是不大于它的
 * @author chenxiaokang
 *
 */
public class Ques1679 {
	
	public void mergeSort(int[] arr,int n){
		this.mergeSort(arr,0,n-1);
	}
	
	private void mergeSort(int[] arr,int l,int r){
		
		if(l >= r)return;
		
//		if( l - r <= 15){
//			insertionSort(arr,l,r);
//			return;
//		}
		
		int mid = (l + r)/2;
		this.mergeSort(arr,l,mid);
		this.mergeSort(arr,mid+1,r);
		if(arr[mid] > arr[mid + 1])
			this.merge(arr,l,mid,r);
	}
	
	private void merge(int[] arr,int l,int mid,int r){
		int[] temp = new int[r - l + 1];
		for(int i = l;i <= r; i++){
			temp[i - l] = arr[i];
		}
		
		int i = l,j = mid + 1;
		
		for(int k = l;k <=r;k ++){
			if(i > mid){
				arr[k] = temp[j - l];
				j++;
			}else if(j > r){
				arr[k] = temp[i - l];
				i++;
			}else if(temp[i - l] < temp[j -l]){
				arr[k] = temp[i-l];
				i ++;
			}else{
				arr[k] = temp[j - l];
				j ++;
			}
		}
	}
	
//	public int findFirstEqualLarger(int[] array, int key) {
//	    int left = 0;
//	    int right = array.length - 1;
//
//	    // 这里必须是 <=
//	    while (left <= right) {
//	        int mid = (left + right) / 2;
//	        if (array[mid] >= key) {
//	            right = mid - 1;
//	        }
//	        else {
//	            left = mid + 1;
//	        }
//	    }
//	    return left;
//	}
	
	public int findLastEqualSmaller(int[] array, int key) {
	    int left = 0;
	    int right = array.length - 1;

	    // 这里必须是 <=
	    while (left <= right) {
	        int mid = (left + right) / 2;
	        if (array[mid] > key) {
	            right = mid - 1;
	        }
	        else {
	            left = mid + 1;
	        }
	    }
	    return right;
	}

	
	public void go(){
		Scanner scan = new Scanner(System.in);
		int n,m,key;
		int[] arr1,arr2;
		while(scan.hasNext()){
			n = scan.nextInt();
			m = scan.nextInt();
			arr1 = new int[n];
			arr2 = new int[m];
			for (int i = 0; i < n; i++) {
				arr1[i] = scan.nextInt();
			}
			for (int i = 0; i < m; i++) {
				arr2[i] = scan.nextInt();
			}
			this.mergeSort(arr1, n);
//			for(int a : arr1){
//				System.out.print(a+" ");
//			}
//			System.out.println();
			for (int i = 0; i < arr2.length; i++) {
				key = this.findLastEqualSmaller(arr1, arr2[i]);
				System.out.println(key+1);
			}
			
		}
	}
	
	public static void main(String[] args) {
		new Ques1679().go();
	}
}
